package com.ukao.pad.ui.writeVipCard;


import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.ukao.pad.R;
import com.ukao.pad.base.BaseFragment;
import com.ukao.pad.widget.StateButton;
import com.ukao.pad.widget.StateImageView;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * 写会员卡 读卡
 */
public class GeneralCardFragment extends BaseFragment {


    @BindView(R.id.back_btn)
    StateImageView backBtn;
    @BindView(R.id.card_txt)
    TextView cardTxt;
    @BindView(R.id.card_number)
    TextView cardNumber;
    @BindView(R.id.card_layout)
    LinearLayout cardLayout;
    @BindView(R.id.riid_btn)
    TextView riidBtn;
    @BindView(R.id.read_card_btn)
    StateButton readCardBtn;
    Unbinder unbinder;
    private String mParam1;
    private String mParam2;


    public static GeneralCardFragment newInstance(String param1, String param2) {
        GeneralCardFragment fragment = new GeneralCardFragment();
        Bundle args = new Bundle();
        args.putString(ARG_PARAM1, param1);
        args.putString(ARG_PARAM2, param2);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            mParam1 = getArguments().getString(ARG_PARAM1);
            mParam2 = getArguments().getString(ARG_PARAM2);
        }
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.fragment_general_card, container, false);
        unbinder = ButterKnife.bind(this, view);
        return view;
    }

    @Override
    protected void initView() {


    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }

    @OnClick({R.id.back_btn, R.id.riid_btn, R.id.read_card_btn})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.back_btn:
                finish();
                break;
            case R.id.riid_btn:
                cardTxt.setTextColor(resources.getColor(R.color.white));
                cardNumber.setTextColor(resources.getColor(R.color.white));
                cardLayout.setBackgroundResource(R.drawable.shape_vip_radius2);
                riidBtn.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        finish();
                    }
                }, 800);
                break;
            case R.id.read_card_btn:
                break;
        }
    }
}